<template>
	<view class="content">
		<view class="send">
			<view class="form">
				<view class="formItem f16 mgb16">
					<view class="text rightTime btn" @tap="confirm()">确定</view>
				</view>
				<view class="formItem f16" @tap="selectItem(i)" v-for="(item,i) in list" :key="i">
					<view class="text">{{item}}{{option.key=="warrantyPeriod"?'天':''}}</view>
					<view class="text rightTime btnicont">
						<icon class="iconfont icondui2 hascolor " type=""  v-show="checkeindex ===i"/>
					</view>
				</view>
				<!-- <view class="formItem f16" @tap="selectItem(item)" v-for="(item,i) in list" :key="i">
					<view class="text">{{item.value}}</view>
					<view class="text rightTime btnicont">
						<icon class="iconfont icondui2 hascolor " type=""  v-show="item.checke"/>
					</view>
				</view> -->
			</view>
		</view>
		
	</view>
</template>


<script>
	export default {
		data() {
			return {
				option:"",
				list:"",
				checkeindex:null,
				svcType:['开启','更换'],
				warrantyPeriod:['90','180','365'],
				doorType:[],
				lockType:[]
			}
		},
		onLoad(option) {
			console.log(option)
			this.option=option
			this.getSelectList();
			// this.list = this.$data[option.key]
			
				/* 
				/svcDict/getDoorType 获取门型列表
				/svcDict/getLockType 获取锁型列表 
				 */
		},
		methods: {
			onchange(){},
			getSelectList(){
				let s = '';
				if(this.option.key ==='doorType'){
					s = 's_getDoorType'
				}else if(this.option.key ==='lockType'){
					s = 's_getLockType'
				}else{
					this.list = this.$data[this.option.key]
					this.option.value?this.checkeindex = this.list.indexOf(this.option.value):''
					return
				}
				this.postApi(s,'GET',{loading:true}).then(res=>{
					console.log(res)
					this.list = this.$data[this.option.key] = res.data
					this.option.value?this.checkeindex = this.list.indexOf(this.option.value):''
				}).catch(err=>{
					
				})
			},
			selectItem(i){
				// this.$data[item.key].forEach(t=>{
				// 	t.checke=false
				// })
				// item.checke=true
				this.checkeindex = i
			},
			confirm(){
				let pages = getCurrentPages();  //获取所有页面栈实例列表
				let nowPage = pages[ pages.length - 1];  //当前页页面实例
				let prevPage = pages[ pages.length - 2 ];  //上一页页面实例
				console.log(prevPage)
				prevPage.$vm.formData[this.option.key] =this.list[this.checkeindex];   //修改上一页data里面的searchVal参数值为1211
				uni.navigateBack({
					delta:1
				})
			}
		}
	}
</script>

<style lang="less">
	@import '@/common/common.less';
	.content{
		display: flex;
		flex-direction: column;
		height: 100%;
		.topButton{
			height: 104rpx;
			background-color: #FFFFFF;
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 17rpx;
			.lefticon{
				margin-left: 40rpx;
				color: @primary-color;
				font-size: 18px;
			}
			.button{
				width: 112rpx;
				height: 60rpx;
				background-color: @primary-color;
				text-align: center;
				line-height: 60rpx;
				margin-right: 33rpx;
				border-radius: 10rpx;
				color: #FFFFFF;
			}
		}
		.already,.send{
			.cost{
				background-color: #FFFFFF;
				margin-bottom: 16rpx;
			}
			.form{
				.formItem{
					border-bottom: 1rpx solid #e1e1e1;
					display: flex;
					flex-direction: row;
					padding-left: 39rpx;
					height: 101rpx;
					align-items: center;
					position: relative;
					background-color: #FFFFFF;
					.lefticon{
						margin-right: 28rpx;
						color: @primary-color;
					}
					.text{
						color: #555555;
						margin-right: 60rpx;
						width: 144rpx;
					}
					.text2{
						color: #555555;
						margin-right: 60rpx;
					}
					.rightTime{
						position: absolute;
						right: 0;
						margin-right:0 ;
					}
					.hascolor{
						color: @primary-color;
					}
					.btn{
						background-color: @primary-color;
						width: 90rpx;
						color: #FFFFFF;
						text-align: center;
						border-radius:6rpx ;
						padding: 5rpx 0;
						margin-right: 50rpx;
					}
					.btnicont{
						width: 90rpx;
						text-align: right;
						border-radius:6rpx ;
						padding: 5rpx 0;
						margin-right: 50rpx;
					}
					.edbtn{
						background-color: #7f7f7f;
					}
				}
				.mgb16{
					margin-bottom: 16rpx;
				}
				.focus{
					border-bottom: 1rpx solid @primary-color;
				}
				.textare{
					border-bottom: 1rpx solid #e1e1e1;
					display: flex;
					flex-direction: column;
					padding-left: 39rpx;
					position: relative;
					background-color: #FFFFFF;
					padding-top: 10rpx;
					padding-bottom:40rpx;
					.fakeInput{
						display: flex;
						flex-direction: row;
						.text{
							margin-right: 20rpx;
							width: auto;
						}
						
					}
					.text{
						color: #555555;
						margin-right: 60rpx;
						width: 144rpx;
					}
					.biginput{
						margin-top:15rpx;
						width: 90%;
						border: 1rpx solid #e1e1e1;
						padding:10rpx;
						min-height: 200rpx;
						vertical-align: middle;
					}
				}
			}
			
		}
		.fake{
			color: #d7d7d7 !important;
		}
		
	}
	
</style>
